#ifndef APPFACTORY_H
#define APPFACTORY_H

#include <QString>
#include <QSettings>
#include <QFile>
#include <QWebView>
#include <QNetworkReply>
#include <QNetworkProxy>
#include <QNetworkProxyFactory>
#include <QWebSettings>
#include <QDebug>
#include <QTextEdit>

#include "definitions.h"


class AppFactory {

	private:

		AppFactory() { }
		~AppFactory() { }

	public:

        // Public pointers for both settings objects.
        static QSettings *settings;
        static QWebSettings *webSettings;

		// Sets up application-wide settings for QWebViev component.
        static void setupWebSettings(QWebSettings *settings);

        // Sets up applications-wide settings.
        static QSettings::Status setupSettings();

        // Keeps settings in sync and returns its current status.
        static QSettings::Status checkSettings();

        // Returns string representation of QNetworkReply::NetworkError.
        static QString getNetCodeError(QNetworkReply::NetworkError code);

        // Sets proxy.
        static void setApplicationProxy();

        // Copies settings from given settings into particular QWebView's settings.
        static void applyWebSettings(QWebSettings *settings, QWebView *view);

		static QString latestVersion(const QString &url);

		//////////////
		// HTML Stuff
		//////////////

		// Returns html string with stripped escape characters (ie. &amp; => &)
		static QString deEscape(const QString &html);

		// Returns text converted to plain text from html. Tags and escape sequences are stripped.
		static QString toPlainText(const QString &html);

};

#endif // APPFACTORY_H
